function HandleParcelInformation(gui, operator, now, options,menu) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  
  this._options = options
  this._menu = menu;
  this._identifiers = (options && options.p) ? options.p : [];
  //this._branch = (options && options.b) ? options.b : '';
  this._template = (options && options.t) ? options.t : '';
  
    switch(this._menu)
   {
   case 1:
     this._branch ='{{$smarty.const.NEWYORK|escape:javascript}}';
     break
     
   case 2:
     this._branch ='{{$smarty.const.SYDNEY|escape:javascript}}';
     break
     
   case 3:
     this._branch ='{{$smarty.const.MELBOURNE|escape:javascript}}';
     break
     
   case 4:
     this._branch ='{{$smarty.const.AUCKLAND|escape:javascript}}';
     break
     
   case 5:
     this._branch ='{{$smarty.const.XTRAORDINARY|escape:javascript}}';
     break
               
   case 6:
     this._branch ='{{$smarty.const.BRISBANE|escape:javascript}}';
     break
     
   default:
     this._branch ='{{$smarty.const.NEWYORK|escape:javascript}}';
   }
  
  this._popupBox = new PopupBox(); 
  
  this._createElements();
};

HandleParcelInformation.prototype._createElements = function() {
  var pos = [window.screen.width / 2, window.screen.height / 5];
  MiscUtils.load(this._popupBox, pos, 'It may take several seconds. Please wait...');
  
  /*if (this._branch == '{{$smarty.const.NEWYORK|escape:javascript}}') {
    this._menu = JSON.stringify({ a: 1, b: 5, c: 1});
  } else if (this._branch == '{{$smarty.const.SYDNEY|escape:javascript}}') {
    this._menu = JSON.stringify({ a: 1, b: 5, c: 2});
  } else if (this._branch == '{{$smarty.const.AUCKLAND|escape:javascript}}') {
    this._menu = JSON.stringify({ a: 1, b: 5, c: 4});
  } else if (this._branch == '{{$smarty.const.MELBOURNE|escape:javascript}}') {
    this._menu = JSON.stringify({ a: 1, b: 5, c: 3});
  } else if (this._branch == '{{$smarty.const.XTRAORDINARY|escape:javascript}}') {
    this._menu = JSON.stringify({ a: 1, b: 5, c: 5});
  } else if (this._branch == '{{$smarty.const.BRISBANE|escape:javascript}}') {
    this._menu = JSON.stringify({ a: 1, b: 5, c: 6});
  }*/
  
  this._loadData();
};

HandleParcelInformation.prototype._verifyData = function() {
  if (this._couriers) {
    this._updateElements();
  }
};

HandleParcelInformation.prototype._loadData = function() {
  this._couriers = null;
  this._parcels = null;
  
  this._retrieveCouriers();
  this._retrieveParcels();
};



HandleParcelInformation.prototype._retrieveCouriers = function() {
  var _self = this;

  new RequestUtils()._mysql('icourier', null, function(result, params) { _self._couriers = result.data;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php'});   
};

HandleParcelInformation.prototype._retrieveParcels = function(page, condition) {
  var _self = this;
  if(this._parcelid){
      condition = (condition) ? condition.replace('(' + this._query + ')' + ' AND ', '') : '';
      
      var joins = '&selects=1' + '&purchaseitems=0' + '&preconusers=0' + '&events=0' + '&tracks=0' + '&produces=0' + '&notes=1';
      var args = '&c=(' + this._query + ')' + ((condition) ? (' AND (' + condition + ')') : '') + ((this._parcelid) ? (' AND d.e_oid = (' + this._parcelid + ')') : '') + '&p=' + ((page) ? page : 1) + '&s=20' + '&o=d.createdDate' + '&q=ASC' + joins;
      new RequestUtils()._mysql('parcels', args, function(result, params) { _self._parcels = result.data;
                                                                             _self._parameters = result;
                                                                             _self._verifyData.call(_self);
                                                                            }, { php: 'customphp/produceread.php'});
  }else{
    this._parcels = [];
  
  }
};

HandleParcelInformation.prototype._updateElements = function() {
  var _self = this;
  DlmanageUtils.clear(this._gui);
  this._popupBox._close();
  
  //var branch = (this._produces.length > 0) ? this._produces[0].branch : '';
  //var host = (this._produces.length > 0) ? this._produces[0].host : '';
  
  
  this._gui.courier.options[this._gui.courier.options.length] = new Option('');
  for (var i = 0, il = this._couriers.length; i < il; i++) {
    var courier = this._couriers[i];
    var option = new Option(courier.name);
    this._gui.courier.options[this._gui.courier.options.length] = option;
    if (option.text == this._parcels.courier) {
      this._gui.courier.selectedIndex = this._gui.courier.options.length - 1;
    }
  }
  
  //this._gui.name.value = this._lastProduce.receiver;
  //this._gui.num.value = this._lastProduce.address;
  //this._gui.destination.value = this._lastProduce.code;
  /*---------------zjx----------------*/
  //this._gui.name.onchange = function() { _self._lastProduce.receiver = this.value; };
  //this._gui.num.onchange = function() { _self._lastProduce.address = this.value; };
  //this._gui.destination.onchange = function() { _self._lastProduce.code = this.value; };
  /*---------------------------------*/
  this._gui.add.onclick = function() { var object = ICourier.instance();
                                      var div = document.createElement('div');
                                      var func1 = function() { _self._popupBox._close();
                                                               _self._parcels.courier = object.name;
                                                               new RequestUtils()._mwrite('icourier', [object], [], function() { _self._retrieveCouriers.call(_self); }, {php: 'customphp/mysqlwrite.php', pos: DOMUtils.findPos(_self._gui.add) });
                                                             };
                                      var func2 = function() { _self._popupBox._close();
                                                             };
                                      MiscUtils.dialog(_self._popupBox, DOMUtils.findPos(this), div, func1, func2, { ok: 'Add' });
                                      new DialogIObject(div, object, {php: 'customphp/mysqlread.php', name: 'icourier', title: 'Couriers'});
                                    };
  
  this._gui.send.onclick = function() { var str = '';
                                        if (_self._gui.name.value == '') {
                                          str = str + '名称,';
                                        } 
                                        if(_self._gui.num.value == '') {
                                          str = str + '数量,';
                                        }
                                        if(_self._gui.destination.value == '') {
                                          str = str + '目的地 ,';
                                        }
                                        if (_self._gui.courier.value == '') {
                                          str = str + '邮寄公司,';
                                        } 
                                         
                                        if (_self._gui.name.value == '' || _self._gui.num.value == '' || _self._gui.destination.value == '' || _self._gui.courier.value == '' ) {
                                          window.alert(str.substring(0, str.length - 1) + ' 未填写');
                                        } else {
                                          var tmp = {};
                                          tmp.trackId = MiscUtils.unique();
                                          tmp.createdDate = _self._now;
                                          tmp.account = _self._operator.account;
                                          tmp.name = _self._gui.name.value;
                                          tmp.num = _self._gui.num.value;
                                          tmp.destination = _self._gui.destination.value;
                                          tmp.courier = _self._gui.courier.value;
                                          tmp.statues= 's';
                                          tmp.receivedDate = null;
                                          tmp.raccount = null;                                          
                                          tmp.branch = _self._branch;
                                          console.log(tmp);
                                          //function() { history.back(); }
                                          new RequestUtils()._write2({ n: 'parcels', a: tmp}, function() { history.back(); }, { php: Constant.FACTORY + '/customphp/mysqlwrite4.php', pos: DOMUtils.findPos(this) });
                                        }
                                      };
  
  //this._gui.cancel.onclick = function() { location.href = '?p=pagefactory&t=' + _self._template + '&m=' + _self._menu};
  this._gui.cancel.onclick =function() { history.back(); };
  //new TableProducts(this._gui.products, this._produces, { user: this._operator, date: this._now, callbackFunc: function() { _self._updateElements.call(_self); } });
};